﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BL.BIZControls
{
    public partial class ControlContainerButtonsGUI : System.Web.UI.UserControl
    {
       
        
        public event ButtonsHandler ButtonsClick;


        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
        }

        public void SetValGroupPrefix(string prefix)
        {
            btnCancel.ValidationGroup = prefix + "_CLOSE";
            btnDelClose.ValidationGroup = prefix + "_DELETE";
            btnDo.ValidationGroup = prefix + "_SAVE";
            btnOK.ValidationGroup = prefix + "_SAVE";

        }

        public void ShowButtons(bool OK, bool Cancel, bool DO, bool Delete)
        {
            if (OK || Cancel || DO || Delete)
            {
                this.Visible = true;
            }
            else
            {
                this.Visible = false;
            }

            btnOK.Visible = OK;
            btnCancel.Visible = Cancel;
            btnDo.Visible = DO;
            btnDelClose.Visible = Delete;
        }

        protected void btnDelClose_Command(object sender, CommandEventArgs e)
        {
            if (ButtonsClick != null)
                ButtonsClick(this, ActionType.Delete);
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (ButtonsClick != null)
                ButtonsClick(this, ActionType.SaveClose);
        }

        protected void btnDo_Click(object sender, EventArgs e)
        {
            if (ButtonsClick != null)
                ButtonsClick(this, ActionType.Save);
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            if (ButtonsClick != null)
                ButtonsClick(this, ActionType.Cancel);
        }
    }
}